package com.openbravo.pos.inventory;

import com.openbravo.basic.BasicException;
import com.openbravo.data.gui.ComboBoxValModel;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.SentenceList;
import com.openbravo.data.loader.SerializerRead;
import com.openbravo.data.loader.SerializerWrite;
import com.openbravo.data.loader.SerializerWriteString;
import com.openbravo.data.loader.StaticSentence;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.AppView;
import com.openbravo.pos.reports.ReportEditorCreator;

import java.awt.Component;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.LayoutStyle;
import javax.swing.LayoutStyle.ComponentPlacement;

public class AttributeSetFilter extends JPanel
  implements ReportEditorCreator
{
  private SentenceList attusesent;
  private ComboBoxValModel attusemodel;
  private JComboBox jAttrSet;
  private JLabel jLabel8;

  public AttributeSetFilter()
  {
    initComponents();
  }

  public void init(AppView paramAppView)
  {
    this.attusesent = new StaticSentence(paramAppView.getSession(), "SELECT ID, NAME FROM ATTRIBUTESET ORDER BY NAME", null, new SerializerRead()
    {
      public Object readValues(DataRead paramDataRead)
        throws BasicException
      {
        return new AttributeSetInfo(paramDataRead.getString(1), paramDataRead.getString(2));
      }
    });
    this.attusemodel = new ComboBoxValModel();
  }

  public void activate()
    throws BasicException
  {
    List localList = this.attusesent.list();
    this.attusemodel = new ComboBoxValModel(localList);
    this.attusemodel.setSelectedFirst();
    this.jAttrSet.setModel(this.attusemodel);
  }

  public SerializerWrite getSerializerWrite()
  {
    return SerializerWriteString.INSTANCE;
  }

  public Component getComponent()
  {
    return this;
  }

  public void addActionListener(ActionListener paramActionListener)
  {
    this.jAttrSet.addActionListener(paramActionListener);
  }

  public void removeActionListener(ActionListener paramActionListener)
  {
    this.jAttrSet.removeActionListener(paramActionListener);
  }

  public Object createValue()
    throws BasicException
  {
    AttributeSetInfo localAttributeSetInfo = (AttributeSetInfo)this.attusemodel.getSelectedItem();
    return localAttributeSetInfo == null ? null : localAttributeSetInfo.getId();
  }

  private void initComponents()
  {
    this.jLabel8 = new JLabel();
    this.jAttrSet = new JComboBox();
    this.jLabel8.setText(AppLocal.getIntString("label.attributeset"));
    GroupLayout localGroupLayout = new GroupLayout(this);
    setLayout(localGroupLayout);
    localGroupLayout.setHorizontalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout.createSequentialGroup().addContainerGap().addComponent(this.jLabel8, -2, 110, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jAttrSet, -2, 220, -2).addContainerGap()));
    localGroupLayout.setVerticalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout.createSequentialGroup().addContainerGap().addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel8).addComponent(this.jAttrSet, -2, 20, -2)).addContainerGap(-1, 32767)));
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.inventory.AttributeSetFilter
 * JD-Core Version:    0.6.0
 */